<?php

/**
 * EmsSection form base class.
 *
 * @method EmsSection getObject() Returns the current form's model object
 *
 * @package    ems
 * @subpackage form
 * @author     Jacobo Martínez
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseEmsSectionForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'                   => new sfWidgetFormInputHidden(),
      'title'                => new sfWidgetFormInputText(),
      'has_featured_block'   => new sfWidgetFormInputCheckbox(),
      'has_banner'           => new sfWidgetFormInputCheckbox(),
      'has_menu'             => new sfWidgetFormInputCheckbox(),
      'has_form'             => new sfWidgetFormInputCheckbox(),
      'has_pagination'       => new sfWidgetFormInputCheckbox(),
      'pagination_parameter' => new sfWidgetFormInputText(),
      'published'            => new sfWidgetFormInputCheckbox(),
      'is_subsection'        => new sfWidgetFormInputCheckbox(),
      'has_subsection'       => new sfWidgetFormInputCheckbox(),
      'is_enabled'           => new sfWidgetFormInputCheckbox(),
      'portal_id'            => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('EmsPortal'), 'add_empty' => false)),
      'header_id'            => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('EmsHeader'), 'add_empty' => true)),
      'footer_id'            => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('EmsFooter'), 'add_empty' => true)),
      'type_id'              => new sfWidgetFormInputText(),
      'css_id'               => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('EmsCss'), 'add_empty' => false)),
      'created_at'           => new sfWidgetFormDateTime(),
      'updated_at'           => new sfWidgetFormDateTime(),
    ));

    $this->setValidators(array(
      'id'                   => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id')), 'empty_value' => $this->getObject()->get('id'), 'required' => false)),
      'title'                => new sfValidatorString(array('max_length' => 100)),
      'has_featured_block'   => new sfValidatorBoolean(),
      'has_banner'           => new sfValidatorBoolean(),
      'has_menu'             => new sfValidatorBoolean(),
      'has_form'             => new sfValidatorBoolean(),
      'has_pagination'       => new sfValidatorBoolean(array('required' => false)),
      'pagination_parameter' => new sfValidatorPass(array('required' => false)),
      'published'            => new sfValidatorBoolean(array('required' => false)),
      'is_subsection'        => new sfValidatorBoolean(array('required' => false)),
      'has_subsection'       => new sfValidatorBoolean(array('required' => false)),
      'is_enabled'           => new sfValidatorBoolean(array('required' => false)),
      'portal_id'            => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('EmsPortal'))),
      'header_id'            => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('EmsHeader'), 'required' => false)),
      'footer_id'            => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('EmsFooter'), 'required' => false)),
      'type_id'              => new sfValidatorInteger(array('required' => false)),
      'css_id'               => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('EmsCss'))),
      'created_at'           => new sfValidatorDateTime(),
      'updated_at'           => new sfValidatorDateTime(),
    ));

    $this->widgetSchema->setNameFormat('ems_section[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'EmsSection';
  }

}
